<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<gcm-red-bag :money="12.98" :options="redBagConfig" :rbagShow="rbagShow" @onConfirm="onConfirm" @onClose="onClose" @onCover="onCover"></gcm-red-bag>
	</view>
</template>

<script>
	import gcmRedBag from "@/components/gcm-red-bag/gcm-red-bag.vue"
	
	export default {
		components: {
			gcmRedBag
		},
		data() {
			return {
				title: 'Hello',
				redBagConfig: {
					userName: '萨啦咪红包',
					coverTitle: '恭喜发财',
					openTitle: '恭喜您获得',
					openTips: '已存入钱包，可直接体现',
					btnText: "确认收款",
				},
				rbagShow: true
			}
		},
		onLoad(option) {
			if (option.id == undefined || option.id == null)
				return
			// this.getRedPacket()
		},
		methods: {
			// 点击确认红包按钮事件
			onConfirm() {},
			// 关闭红包时触发
			onClose() {},
			// 开启红包时触发
			onCover() {},
			
			// 检查id是否可以使用
			// 通过id调用红包信息
			getRedPacket() {
				console.log("从数据库刷新设备状态")
				let self = this
				uni.request({
					url: getApp().globalData.base_url + '/app/device/search-devices-online-state-fordb',
					method: 'POST',
					header: {
						Authorization: getApp().globalData.base_token
					},
					data: {},
					success: (res) => {
						if (res.data.code == 200 && res.data.data.length > 0) {
							for (var i = 0; i < res.data.data.length; i++) {
								for (var j = 0; j < self.deviceList.length; j++) {
									if (self.deviceList[j].fId == res.data.data[i].fId) {
										self.deviceList[j].tOnline = res.data.data[i].tOnline
										break
									}
								}
							}
						}
					}
				})
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>